package cn.mybatis.plugin.pagehelper;

/**
 * @author: 张澎_9970
 * @date: 2022.1.18 上午 12:02
 */
public class PageHelper {

    private final static ThreadLocal<Page> THREAD_PAGE = new ThreadLocal<>();

    public static <T> Page<T> startPage(int pageNum, int pageSize) {
        Page<T> page = new Page<>(pageNum, pageSize);
        pushPage(page);

        return page;
    }

    private static void pushPage(Page page) {
        THREAD_PAGE.set(page);
    }

    public static <T> Page<T> getPage() {
        return THREAD_PAGE.get();
    }

    public static void clearPage() {
        THREAD_PAGE.remove();
    }

}
